<%@page import="com.railway.news.model.*" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/commons/taglibs.jsp" %>
<html>
<head>
	<title><%=NewsColums.TABLE_ALIAS%>编辑</title>
	<link type="text/css" rel="stylesheet" href="${ctx}/css/themes/default/easyui.css">
	<link type="text/css" rel="stylesheet" href="${ctx}/css/themes/icon.css">
	<link type="text/css" rel="stylesheet" href="${ctx}/css/default.css" />
	
	<link rel="stylesheet" href="${ctx}/css/ztree.css" type="text/css">
	<link rel="stylesheet" href="${ctx}/css/zTreeStyle/zTreeStyle.css" type="text/css">	
	<script type="text/javascript" src="${ctx}/scripts/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="${ctx}/scripts/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${ctx}/scripts/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="${ctx}/scripts/xheditor-1.1.12-zh-cn.min.js"></script>		
	<script type="text/javascript" src="${ctx}/scripts/jquery.ztree.core-3.0.min.js"></script>
	<script type="text/javascript" src="${ctx}/scripts/jquery.ztree.excheck-3.0.min.js"></script>
	<SCRIPT type="text/javascript">

		var setting = {
			check: {
				enable: true,
				chkStyle: "radio",
				radioType: "all"
			},
			view: {
				dblClickExpand: false
			},
			data: {
				simpleData: {
					enable: true
				}
			},
			callback: {
				onClick: onClick,
				onCheck: onCheck
			}
		};	

		function onClick(e, treeId, treeNode) {
			var zTree = $.fn.zTree.getZTreeObj("treeDemo");
			zTree.checkNode(treeNode, !treeNode.checked, null, true);
			return false;
		}

		function onCheck(e, treeId, treeNode) {
			var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
			nodes = zTree.getCheckedNodes(true),
			v = "";
			for (var i=0, l=nodes.length; i<l; i++) {
			    form1.catId.value += nodes[i].id;
				v += nodes[i].name + ",";

			}
			if (v.length > 0 ) v = v.substring(0, v.length-1);
			var cityObj = $("#citySel");
			cityObj.attr("value", v);
		}

		function showMenu() {
			var cityObj = $("#citySel");
			var cityOffset = $("#citySel").offset();
			$("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");

			$("body").bind("mousedown", onBodyDown);
		}
		function hideMenu() {
			$("#menuContent").fadeOut("fast");
			$("body").unbind("mousedown", onBodyDown);
		}
		function onBodyDown(event) {
			if (!(event.target.id == "menuBtn" || event.target.id == "citySel" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
				hideMenu();
			}
		}

		$(document).ready(function(){

              $.get("${ctx}/news/News/getNewsById.do", {
                Action:"get",id:form1.id.value}, function (data, textStatus){			
	            var objs = eval("["+data+"]");	                    
                if(objs[0].context == undefined){        
                   return;
                }
                 $('#contentText').xheditor().toggleSource(true) ;
                 $('#contentText').xheditor().setSource(objs[0].context);
                 $('#contentText').xheditor().toggleSource(false) ;
				});	      	
		
		    $.get("${ctx}/news/Category/getCategoryList.do", {
                Action:"get",Name:"user01"}, function (data, textStatus){			
	
                var zNodes = eval(data);

		          $.fn.zTree.init($("#treeDemo"), setting, zNodes);
				});	
			
		});
		//-->
	</SCRIPT>
</head>
<body>
	<form id="form1" action="${ctx}/news/News/update.do" method="post">
	   	<input id="returnUrl" name="returnUrl" type="hidden" 	value="${ctx}/news/News/getNewsByTitle.do?title=${param.title}" >
							
		<input type="submit" value="提交"  />
		<input type="button" value="返回列表" onclick="window.location='${ctx}/news/News/list.do'"/>
		<input type="button" value="后退" onclick="history.back();"/>
		
		<table class="formTable">
			<input type="hidden" id="id" name="id" value="${model.id}"/>
		    <input id="returnUrl" name="returnUrl" value="${requestScope.returnUrl}" type="hidden"/>
		<!-- ONGL access static field: @package.class@field or @vs@field -->
			
			
			<tr>	
				<td class="tdLabel">
					
				</td>	
				<td>
				<input id="catId" name="catId" value="${model.catId}"
				type="hidden"  class="easyui-validatebox"   />
				</td>
			</tr>
			
			
			<tr>	
				<td class="tdLabel">
					<%=NewsColums.ALIAS_TITLE%>:
				</td>	
				<td>
				<input id="title" name="title" value="${model.title}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			

			
			
			<tr>	
				<td class="tdLabel">
					<%=NewsColums.ALIAS_CREATE_TIME%>:
				</td>	
				<td>
				<input value="${model.createTimeString}" id="createTimeString" name="createTimeString"  
				type="text" class="easyui-datebox"   />
				</td>
			</tr>
			
			
			<tr>	
				<td class="tdLabel">
					<%=NewsColums.ALIAS_CONTENT_TEXT%>:
				</td>	
				<td>
		       <textarea class="xheditor {skin:'default'}" id="contentText" name="contentText" value=""  rows="12" cols="80" style="width: 80%">
			      	</textarea>
				</td>
				
			</tr>			

			<tr>	
				<td class="tdLabel">
					<%=NewsColums.ALIAS_FROM_NAME%>:
				</td>	
				<td>
				<input id="fromName" name="fromName" value="${model.fromName}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			
			
			<tr>	
				<td class="tdLabel">
					<%=NewsColums.ALIAS_FROM_URL%>:
				</td>	
				<td>
				<input id="fromUrl" name="fromUrl" value="${model.fromUrl}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			
			
			<!--tr>	
				<td class="tdLabel">
					<%=NewsColums.ALIAS_BROWSE%>:
				</td>	
				<td>
				<input id="browse" name="browse" value="${model.browse}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			
			
			<tr>	
				<td class="tdLabel">
					<%=NewsColums.ALIAS_RECOM%>:
				</td>	
				<td>
				<input id="recom" name="recom" value="${model.recom}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			
			
			<tr>	
				<td class="tdLabel">
					<%=NewsColums.ALIAS_TOP_STATE%>:
				</td>	
				<td>
				<input id="topState" name="topState" value="${model.topState}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr-->
			
			
			<tr>	
				<td class="tdLabel">
					<%=NewsColums.ALIAS_STATE%>:
				</td>	
				<td>
				<input id="state" name="state" value="${model.state}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			 
		</table>
	</form>

 
<div class="content_wrap">
	<div class="zTreeDemoBackground left">
		<ul class="list">
			
			<%=NewsColums.ALIAS_CATEGORY%>: <input id="citySel" type="text" readonly value="" style="width:120px;" onclick="showMenu();" />
		&nbsp;<a id="menuBtn" href="#" onclick="showMenu(); return false;">选择</a>
		</ul>
	</div>
	</div>
	<div id="menuContent" class="menuContent" style="display:none; position: absolute;">
	<ul id="treeDemo" class="ztree" style="margin-top:0; width:180px; height: 300px;"></ul>
</div>
	
</body>
<script>
//begin $(document).ready(handler)
$(function(){
$('#form1').submit(function(){

});}
);//end $(document).ready(handler)
</script>
</html>

